package com.xzzz.irda.registry.service;

import com.xzzz.common.base.util.SystemUtil;
import com.xzzz.common.base.util.spring.SpringUtil;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.serviceregistry.Registration;

import java.net.URI;
import java.util.Map;

public class RedisRegistration implements Registration, ServiceInstance {

    @Override
    public String getInstanceId() {
        return ServiceUtil.buildInstanceId(this);
    }

    @Override
    public String getServiceId() {
        return SpringUtil.getAppName();
    }

    @Override
    public String getHost() {
        return SystemUtil.getIp();
    }

    @Override
    public int getPort() {
        return Integer.parseInt(SpringUtil.getPort());
    }

    @Override
    public boolean isSecure() {
        return false;
    }

    @Override
    public URI getUri() {
        return ServiceUtil.buildUri(this);
    }

    @Override
    public Map<String, String> getMetadata() {
        return null;
    }
}
